let showBanner = function () {
    $.ajax({
        type: 'get',
        url: '/admin/showJoinBanner',
        data: '',
        success: function (data) {
            let showTop = template('banner_top_temp', {
                list: data
            })
            $('#banner_top_img').html(showTop)
        }
    })
}
showBanner()
// 更换图片
$('#banner_top_img').on('change', ".upfile", function () {
    // 2.获取input的文件信息
    let file = $(this)[0].files[0];
    // 3.实例化formdata
    let formdata = new FormData();
    // 4.把input的文件信息添加到formdata
    formdata.append('avatar', file);
    // console.log(formdata);
    let ids = $(this).data('id')
    $.ajax({
        type: 'post',
        url: '/admin/upImgJoin',
        data: formdata,
        contentType: false,
        processData: false,
        success: function (data) {
            if (data.code == 31101) {
                $.ajax({
                    type: 'post',
                    url: '/admin/pushBannerJoin',
                    data: {
                        keys: ids,
                        mas: data.pic
                    },
                    success: function (datas) {
                        if (datas.code == 31102) {
                            alert('更新成功')
                            showBanner()
                        } else {
                            alert('修改失败')
                        }

                    }
                })
            } else {
                alert('修改失败')
            }

        }
    })
})


// 修改文案
$('#banner_top_img').on('click','#upOffic',function(){
    let ids = $(this).data('id')
    let fordata = $(this).prev()
    let title = fordata.find('#titme').val()
    let con = fordata.find('#conent').val()
    $.ajax({
        type:'post',
        url:'/admin/pushOfficJoin',
        data:{id:ids,title:title,conent:con},
        success:function(data){
            if(data.code == 41101){
                alert('修改成功')
                showBanner()
            }else{
                alert('修改失败')
            }
        }
    })
})